layui.use(['form','jquery','layer'], function(){
  var form = layui.form
  ,layer = layui.layer
  ,$ = layui.jquery;
/*  $('#dosubmit').click(function(){
    var username = $('#username').val();
    var password = $('#password').val();
    var pwdconfirm = $('#pwdconfirm').val();
    var email = $('#email').val();
    var nickname = $('#nickname').val();
    var protocol = $('#protocol').attr('checked');
    if(username.length < 2 || username.length > 20){
        layer.msg('用户名长度位2-20位！',{icon: 2,time: 500});
        return false;
    }
    if(!new RegExp("^[0-9a-zA-Z]+$").test(username)){
        layer.msg('用户名只能数字加字母',{icon: 2,time: 500});
        return false;   
    }
    if(password.length < 6 || password.length > 20){
        layer.msg('密码长度位6-20位！',{icon: 2,time: 500});
        return false;
    }
    if(password != pwdconfirm){
        layer.msg('两次密码输入不一致！',{icon: 2,time: 500});
        return false;
    }
    if(!new RegExp("^[a-z0-9]+([._\\-]*[a-z0-9])*@([a-z0-9]+[-a-z0-9]*[a-z0-9]+.){1,63}[a-z0-9]+$").test(email)){
        layer.msg('邮箱不正确，请输入邮箱！',{icon: 2,time: 500});
        return false;       
    }
    if(!new RegExp("^[a-zA-Z0-9_\u4e00-\u9fa5\\s·]+$").test(nickname)){
        layer.msg('昵称不能有特殊字符！',{icon: 2,time: 500});
        return false;
    }
    if(!protocol){
    	layer.msg('请同意注册协议',{icon: 2,time: 500});
    	return false;
    }*/
	form.verify({
    username: function(value){
      if(value.length < 2 || value.length > 20){
        return '用户名长度为2-20位！';
      }
    }
    ,password: function(value){
      if(value.length < 6 || value.length > 20){
      	return '密码长度为6-20位！';
      }
    }
    ,pwdconfirm: function(value){
      var pwd = $('#password').val();
      if(value != pwd){
      	return '两次密码输入不一致！';
      }
    }
    ,nickname: function(value){
      if(!new RegExp("^[a-zA-Z0-9_\u4e00-\u9fa5\\s·]+$").test(value)){
      	return '昵称不能有特殊字符！';
      }
    }
    ,protocol: function(value){
      if(!$('#protocol').is(':checked')){
      	return '请勾选注册协议！';
      }
    }
  	});
});